#include <iostream>

/*
  二维数组对角线之和
*/
int main(int argc, char const *argv[])
{
  int sum = 0;
  int arr[3][3] = {
      {1, 2, 3},
      {4, 5, 6},
      {7, 8, 9}};

  for (int i = 0; i < 3; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      if ((i == j) || (i + j == 2 && i != j))
      {
        sum += arr[i][j];
      }
    }
  }

  printf("sum = %d\n", sum);

  return 0;
}
